package com.caseProject.puremvc.mediator.gui
{
	import com.caseProject.puremvc.mediator.gui.simple.SimpleGraphic;
	import com.caseProject.puremvc.model.vo.ElementVO;
	
	import flash.events.MouseEvent;

	public class NoteElement extends Element
	{
		private var _simpleGraph:SimpleGraphic;
		private var _enableTransform:Boolean;
		
		public function NoteElement()
		{
			this.enableTransform = false;
			this.draw();
		}
		
		public function get enableTransform():Boolean
		{
			return _enableTransform;
		}
		
		public function set enableTransform(value:Boolean):void
		{
			_enableTransform = value;
		}
		
		public function get simpleGraph():SimpleGraphic
		{
			return _simpleGraph;
		}
		
		override public function draw ():void
		{
			super.draw();
			
			var swc:NoteSWC = new NoteSWC();
			_simpleGraph = new SimpleGraphic(swc);
			this.addChild(simpleGraph);
		}
		
		override protected function onMove(event:MouseEvent):void
		{
			super.onMove(event); 
			
			if (this.simpleGraph.mouseX > this.simpleGraph.width - 30 && 
				this.simpleGraph.mouseY > this.simpleGraph.height - 30 &&
				this._enableTransform) 
			{	
				this.simpleGraph.redraw(this.simpleGraph.mouseX+5, this.simpleGraph.mouseY+5);
				
				ElementVO(this.vo).heightValue = this.simpleGraph.height;
				ElementVO(this.vo).widthValue = this.simpleGraph.width;
			}
		}
		
		override protected function onUp(event:MouseEvent):void
		{
			super.onUp(event);
			this._enableTransform = false;
		}
	}
}